]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
aggregateMenu: Ignore ellipsizable items in width-request
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 4 Oct 2015 01:07:32 +0000 (03:07 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Thu, 15 Oct 2015 17:56:03 +0000 (19:56 +0200)
Some labels in the system status menu - namely network names - are out
of our control, and may thus grow the width "infinitively" unless we
restrict the menu width. So far we have been doing this by setting a
fixed width or max-width, but any value we put there might end up
being too restrictive in some locales. Instead, request a width that
fits all the labels we want to show unellipsized and use that instead
of an arbitrary limit.

https://bugzilla.gnome.org/show_bug.cgi?id=708472

data/theme/gnome-shell-high-contrast.css
data/theme/gnome-shell-sass
data/theme/gnome-shell.css
js/ui/panel.js

index 1be7d648762c5eb3b888bd788b7f9efe502bcbe2..feb2b5008b7a3d3268c38d72540aeb9a1a8a3940 100644 (file)
@@ -823,8 +823,7 @@ StScrollBar {
     color: transparent; }
 
 .aggregate-menu {
-  min-width: 280px;
-  max-width: 400px; }
+  min-width: 280px; }
   .aggregate-menu .popup-menu-icon {
     padding: 0 4px; }
 
index 01253d8545395de215c200cfe1be1b4667b9fa0b..83b896b0e13725d7045ba3708265f6689952586c 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 01253d8545395de215c200cfe1be1b4667b9fa0b
+Subproject commit 83b896b0e13725d7045ba3708265f6689952586c
index db9af9bbac01d49f09fb3eb956a734ddbedb6161..6ae2302f66bd2bcded1fedc96320d2003c24c813 100644 (file)
@@ -823,8 +823,7 @@ StScrollBar {
     color: transparent; }
 
 .aggregate-menu {
-  min-width: 280px;
-  max-width: 400px; }
+  min-width: 280px; }
   .aggregate-menu .popup-menu-icon {
     padding: 0 4px; }
 
index 19336811f11d81eaae7b50cb4668c53a89b45838..3127db03fcf4098938f0df490214a7e6f439b259 100644 (file)
@@ -652,6 +652,39 @@ const PanelCorner = new Lang.Class({
     }
 });
 
+const AggregateLayout = new Lang.Class({
+    Name: 'AggregateLayout',
+    Extends: Clutter.BoxLayout,
+
+    _init: function(params) {
+        if (!params)
+            params = {};
+        params['orientation'] = Clutter.Orientation.VERTICAL;
+        this.parent(params);
+
+        this._sizeChildren = [];
+    },
+
+    addSizeChild: function(actor) {
+        this._sizeChildren.push(actor);
+        this.layout_changed();
+    },
+
+    vfunc_get_preferred_width: function(container, forHeight) {
+        let themeNode = container.get_theme_node();
+        let minWidth = themeNode.get_min_width();
+        let natWidth = minWidth;
+
+        for (let i = 0; i < this._sizeChildren.length; i++) {
+            let child = this._sizeChildren[i];
+            let [childMin, childNat] = child.get_preferred_width(forHeight);
+            minWidth = Math.max(minWidth, childMin);
+            natWidth = Math.max(minWidth, childNat);
+        }
+        return [minWidth, natWidth];
+    }
+});
+
 const AggregateMenu = new Lang.Class({
     Name: 'AggregateMenu',
     Extends: PanelMenu.Button,
@@ -660,6 +693,9 @@ const AggregateMenu = new Lang.Class({
         this.parent(0.0, C_("System menu in the top bar", "System"), false);
         this.menu.actor.add_style_class_name('aggregate-menu');
 
+        let menuLayout = new AggregateLayout();
+        this.menu.box.set_layout_manager(menuLayout);
+
         this._indicators = new St.BoxLayout({ style_class: 'panel-status-indicators-box' });
         this.actor.add_child(this._indicators);
 
@@ -708,6 +744,11 @@ const AggregateMenu = new Lang.Class({
         this.menu.addMenuItem(this._rfkill.menu);
         this.menu.addMenuItem(this._power.menu);
         this.menu.addMenuItem(this._system.menu);
+
+        menuLayout.addSizeChild(this._location.menu.actor);
+        menuLayout.addSizeChild(this._rfkill.menu.actor);
+        menuLayout.addSizeChild(this._power.menu.actor);
+        menuLayout.addSizeChild(this._system.menu.actor);
     },
 });